package cn.icanci.ladybird.service.impl;

import cn.icanci.ladybird.pojo.entity.TicketDetailsTicketClassMiddle;
import cn.icanci.ladybird.dao.TicketDetailsTicketClassMiddleDao;
import cn.icanci.ladybird.service.TicketDetailsTicketClassMiddleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TicketDetailsTicketClassMiddle)表服务实现类
 *
 * @author makejava
 * @since 2020-09-29 20:43:57
 */
@Service("ticketDetailsTicketClassMiddleService")
public class TicketDetailsTicketClassMiddleServiceImpl implements TicketDetailsTicketClassMiddleService {
    @Resource
    private TicketDetailsTicketClassMiddleDao ticketDetailsTicketClassMiddleDao;

    /**
     * 通过ID查询单条数据
     *
     * @param ticketDetailsTicketClassId 主键
     * @return 实例对象
     */
    @Override
    public TicketDetailsTicketClassMiddle queryById(Long ticketDetailsTicketClassId) {
        return this.ticketDetailsTicketClassMiddleDao.queryById(ticketDetailsTicketClassId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TicketDetailsTicketClassMiddle> queryAllByLimit(int offset, int limit) {
        return this.ticketDetailsTicketClassMiddleDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param ticketDetailsTicketClassMiddle 实例对象
     * @return 实例对象
     */
    @Override
    public TicketDetailsTicketClassMiddle insert(TicketDetailsTicketClassMiddle ticketDetailsTicketClassMiddle) {
        this.ticketDetailsTicketClassMiddleDao.insert(ticketDetailsTicketClassMiddle);
        return ticketDetailsTicketClassMiddle;
    }

    /**
     * 修改数据
     *
     * @param ticketDetailsTicketClassMiddle 实例对象
     * @return 实例对象
     */
    @Override
    public TicketDetailsTicketClassMiddle update(TicketDetailsTicketClassMiddle ticketDetailsTicketClassMiddle) {
        this.ticketDetailsTicketClassMiddleDao.update(ticketDetailsTicketClassMiddle);
        return this.queryById(ticketDetailsTicketClassMiddle.getTicketDetailsTicketClassId());
    }

    /**
     * 通过主键删除数据
     *
     * @param ticketDetailsTicketClassId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long ticketDetailsTicketClassId) {
        return this.ticketDetailsTicketClassMiddleDao.deleteById(ticketDetailsTicketClassId) > 0;
    }
}